package top.arryweb.application.controller;


import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import java.math.BigDecimal;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.arryweb.application.common.constant.Result;
import top.arryweb.application.common.constant.StatusCode;
import top.arryweb.application.domain.dto.CreatePaymentOrderDTO;
import top.arryweb.application.domain.pojo.BookKeepPaymentOrder;
import top.arryweb.application.service.IBookKeepPaymentOrderService;

/**
 * <p>
 * 订单流水表 前端控制器
 * </p>
 *
 * @author Arry
 * @since 2021-05-27
 */
@Api(tags = "订单流水")// tags：你可以当作是这个组的名字。
@RestController
@Slf4j
@RequestMapping("/book-keep-payment-order")
public class BookKeepPaymentOrderController {

  @Autowired
  private IBookKeepPaymentOrderService iBookKeepPaymentOrderService;

  @ApiImplicitParams({
      @ApiImplicitParam(name = "username",//参数名字
          value = "测试数据",//参数的描述
          required = false,//是否必须传入
          //paramType定义参数传递类型：有path,query,body,form,header
          paramType = "query"
      )
      ,
      @ApiImplicitParam(name = "password",//参数名字
          value = "测试数据",//参数的描述
          required = false,//是否必须传入
          paramType = "query"
      )
  })

  @ApiOperation(value = "查询所有订单流水", notes = "查询测试")//value：可以当作是接口的简称 notes：接口的描述
  @GetMapping("/findAllPaymentOrder")
  public List<BookKeepPaymentOrder> findAllPaymentOrder() {
    return iBookKeepPaymentOrderService.list();
  }

  @ApiOperation(value = "获取订单流水ID", notes = "生成测试")
  @PostMapping("/getPaymentOrderId")
  public Result<Long> getPaymentOrderId(CreatePaymentOrderDTO createPaymentOrderDTO) {
    Long paymentOrderId = iBookKeepPaymentOrderService.getPaymentOrderId(createPaymentOrderDTO);
    return new Result<>(true, StatusCode.CODE_SUCCESS, "成功获取订单流水ID", paymentOrderId);
  }
}
